<script setup lang="ts">
import { ref } from "vue";
const emits = defineEmits(["sendMsg"]);
const props = defineProps({
  msg: { type: String, default: "当前是子组件的默认值" }
});

const count = ref(0);
const addCount = () => {
  count.value = count.value + 1;
  emits("sendMsg", `count的最新值为: ${count.value}`);
};
</script>

<template>
  <div class="container">
    <span class="bold-text">来自父组件的消息：{{ props.msg }}</span>
    <br />
    <span class="title">子组件：</span>
    <span>计数器值: {{ count }}</span>
    <button @click="addCount">点击增加</button>
    <van-button type="primary" @click="addCount">vant组件点击增加</van-button>

    <!-- slot标签，设置名为customContent插槽 -->
    <slot name="customContent"></slot>
  </div>
</template>

<style lang="scss" scoped>
@import "vant/lib/index.css";
.container {
  display: flex;
  flex-direction: column;
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 8px 16px 0 rgba(37, 43, 58, 0.16);
  width: 180px;
  gap: 16px;
  .title {
    font-weight: bold;
  }
}
</style>
